package com.fc.test.api;

import com.fc.test.service.TAbbFankuiService;
import com.fc.test.util.JsonUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/apiFankuiController")
@Api(value = "意见反馈")
public class ApiFankuiController {

    @Autowired
    private TAbbFankuiService tAbbFankuiService;

    @ResponseBody
    @PostMapping(value="submitFankui",produces = {"application/json; charset=utf-8"})
    @ApiOperation(value = "提交反馈意见")
    public String submitFankui(
            @ApiParam(value = "用户id") @RequestParam(value = "userid") String userid,
            @ApiParam(value = "反馈内容") @RequestParam(value = "content") String content
    ){
        Map<String,Object> resMap = new HashMap<>();
        int flag = tAbbFankuiService.submitFankui(userid,content);
        if(flag>0){
            resMap.put("success",true);
            resMap.put("msg","提交成功");
        }else{
            resMap.put("success",false);
            resMap.put("msg","提交失败");
        }
        return JsonUtil.jsonMapStr(resMap);
    }
}
